#!/usr/bin/python
# -*- coding: UTF-8 -*-
import  time
import os
def PCMainIMGFun(browser,filePath):
    #点击上传图片按钮
    time.sleep(2)
    browser.find_element_by_xpath\
        ('//*[@id="struct-images"]/div/div[2]/div[1]/div[2]/div/div/div/div[1]/div[1]')\
         .click()
    time.sleep(2)
    frame = browser.find_element_by_xpath("/html/body/div[14]/div/div/div/div/iframe")

    #获取frame的句柄
    browser.switch_to.frame(frame)
    time.sleep(5)
    #点击上传图片
    browser.find_element_by_xpath('//*[@id="container"]/div/div[2]/div[2]/div/div[1]/div[2]/div[1]/div[5]')\
        .click()

    #点击上传
    browser.find_element_by_id('uploadBtn').click()

    # 启动AutoIt来控制文件
    callAutoItEXE()

    # #回到主页句柄
    browser.switch_to.default_content()
    time.sleep(50)
    #这个操作是为了关闭上传页面
    onetoone = browser.find_element_by_xpath('//*[@id="struct-imageVideoType"]/div/div[2]/div[1]/div/span/span[1]/label/span')
    browser.execute_script("arguments[0].click();", onetoone)


def callAutoItEXE():
    os.system("F:\soft\MeSoft\AutoIT\AutoItWorks\MainIMG.exe")